package com.iwhalecloud.bss.kite.cucc.web.controller.registration;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.iwhalecloud.bss.kite.client.dto.DataResult;
import com.iwhalecloud.bss.kite.common.constant.ErrorConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.client.dto.webService.CustContractRsp;
import com.iwhalecloud.bss.kite.cucc.client.dto.webService.RegistrationRsp;
import com.iwhalecloud.bss.kite.cucc.service.inf.InfServiceBus;
import com.iwhalecloud.bss.kite.cucc.service.order.RegistrationService;
import com.ztesoft.bss.common.util.ContextUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@RestController
@RequestMapping("/regisTration")
@Api(tags = {"/regisTration - 定制包物联网实名制"})
public class RegisTrationController {

    @Autowired
    private InfServiceBus infServiceBus;
    @Autowired
    private RegistrationService registrationService;
    @ApiOperation(value = "物联网实名制列表", notes = "物联网实名制列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "creator", value = "创建人登录名或手机号"),
        @ApiImplicitParam(name = "transactorName", value = "经办人姓名"),
        @ApiImplicitParam(name = "responsibleName", value = "责任人姓名"),
        @ApiImplicitParam(name = "transactorCertiCode", value = "经办人证件号码"),
        @ApiImplicitParam(name = "responsibleCertiCode", value = "责任人证件号码"),
        @ApiImplicitParam(name = "custId", value = "客户id"),
        @ApiImplicitParam(name = "pageNum", value = "页码", required = true),
        @ApiImplicitParam(name = "pageSize", value = "每页展示", required = true)
    })
    @GetMapping("/list")
    public DataResult<PageInfo<RegistrationRsp>> list(String  creator,String transactorName,String responsibleName,String transactorCertiCode,String responsibleCertiCode,String custId,int pageNum,int pageSize) {
       /* CuccLoginInfoDTO cuccLoginInfo = new CuccLoginInfoDTO();*/
        Map map=new HashMap();
        map.put("USER_CODE",ContextUtil.getLoginInfo().getStaffInfo().getStaffCode());
        map.put("TRANSACTOR_NAME",transactorName);
        map.put("RESPONSIBLE_NAME",responsibleName);
        map.put("TRANSACTOR_CERTI_CODE",transactorCertiCode);
        map.put("RESPONSIBLE_CERTI_CODE",responsibleCertiCode);
        map.put("custId",custId);
        PageInfo<RegistrationRsp> pageInfo = registrationService.registrationInfo(map,pageNum, pageSize);
        return ErrorConsts.SUCCESS.getResult(pageInfo);
    }
    @ApiOperation(value = "物联网实名制详情", notes = "物联网实名制详情")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "iotTagCode", value = "实名制编码"),
        @ApiImplicitParam(name = "sceneInstId", value = "实例id")
    })
    @GetMapping("/detail")
    public DataResult<Map> detail(String  iotTagCode,String sceneInstId) {
       if(KiteStringUtils.isNotEmpty(iotTagCode)){
           registrationService.registrationDetail(ContextUtil.getLoginInfo().getStaffInfo().getStaffCode(),iotTagCode,sceneInstId,null);
       }
       Map map=new HashMap();
       map.put("flag","1");
       return ErrorConsts.SUCCESS.getResult(map);
    }

}
